package com.ror.java.se.reflect;

import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

public class Demo06 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Properties prop = new Properties();
        FileReader fr = new FileReader("src/com/ror/java/se/reflect/prop.properties");
        prop.load(fr);
        String className = (String) prop.get("class");
        String methodName = (String) prop.get("method");
        Class<?> clazz = Class.forName(className);
        Constructor<?> ctor = clazz.getDeclaredConstructor();
        ctor.setAccessible(true);
        clazz.getMethod(methodName).invoke(ctor.newInstance()); //学生学习
        fr.close();
    }
}
